<template>
	<view class="">
		<u-navbar placeholder title="订单" leftIcon=""></u-navbar>
		<u-sticky bgColor="#fff">
			<u-tabs :list="tabList" :current="state.dataIndex" @change="onTabsClick" :activeStyle="{color:'#F7C097'}"
				lineColor="#F7C097" :scrollable="false"></u-tabs>
		</u-sticky>
		<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="data_item" v-for="(item,index) in state.dataList" :key="item.id">
				<view class="data_header">
					<text>订单号: {{item.order_num}}</text>
					<text class="status">{{item.status}}</text>
				</view>
			</view>

		</mescroll-body>

	</view>

</template>

<script setup>
	import { reactive, ref, computed, onMounted } from 'vue';
	import { useStore } from 'vuex';
	import { copyText } from '@/common/hooks.js'
	import { onPageScroll, onReachBottom } from '@dcloudio/uni-app';
	import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js";
	import { userOrderApi} from '@/common/apis.js'
	const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom)
	import { onLoad } from "@dcloudio/uni-app";
	const store = reactive(useStore())
	const tabList = [
		{
			name: '状态1',
			value: "1"
		},
		{
			name: '状态2',
			value: "2"
		},
		{
			name: '状态3',
			value: "3"
		},
	
	]
	const state = reactive({
		dataList: [],
		value: '1',
		dataIndex: 0,
	})

	const onTabsClick = (tabs) => {
		state.value = tabs.value
		getMescroll().resetUpScroll()
	}

	const upCallback = (mescroll) => {
		userOrderApi({  type: state.value }).then(({ data: res}) => {
			const curPageData = res.data.list || [] // 当前页数据
			if (mescroll.num == 1) state.dataList = []; // 第一页需手动制空列表
			state.dataList = state.dataList.concat(curPageData); //追加新数据
			mescroll.endBySize(curPageData.length, res.data.count); //必传参数(当前页的数据个数, 总数据量)
		}).catch(() => {
			mescroll.endErr(); // 请求失败, 结束加载
		})
	}




	onMounted(() => {
	
	})
</script>

<style lang='scss' scoped>
	page {
		background-color: #EEE;
	}

	.data_item {
		background-color: #fff;
		padding: 10px;
		margin-top: 20px;
		font-size: 14px;

		.data_header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: #999;

			.status {
				color: $common-red;
			}
		}

		.data_center {
			border-bottom: 1px solid #EEEEEE;
			border-top: 1px solid #EEEEEE;
			padding: 15px 0;
			margin-top: 15px;
			display: flex;
			justify-content: space-between;

			image {
				width: 100px;
				height: 80px;
			}

			.center_ifno {
				.title {
					font-weight: 700;
				}

				.order_num {
					margin-top: 5px;
				}

				.user_type {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin: 5px 0;

					.user_name {
						color: $common-blue;
					}

					.tags {
						background-color: $common-red;
						color: #fff;
						padding: 3px 10px;
						border-radius: 12px;
					}

					.tags_green {
						background-color: #3C8126;
					}
				}

				.inv_code {
					color: #555;
				}

				.mt3 {
					margin-top: 3px;
				}
			}
		}

		.center_right {
			color: $common-red;
		}

		.data_bottom {
			padding-top: 15px;

			.bottom_info {
				display: flex;
				justify-content: space-between;
				margin-top: 5px;

				.red_color {
					color: $common-red;
				}
			}

			.bottom_btn_group {
				display: flex;
				justify-content: flex-end;
				margin: 20px 0;

				.bottom_btn {
					margin-left: 30px;
					color: #fff;
					background-color: $common-blue;
					padding: 5px 10px;
					border-radius: 5px;
				}

				.red_btn {
					background-color: $common-red;
				}
			}
		}
	}

	.popup_content {
		padding: 10px;
		font-size: 14px;
		width: 320px;

		.popup_header {
			border-bottom: 1px solid #EEE;
			height: 30px;
			display: flex;
			font-weight: 700;
			font-size: 16px;
		}

		.flex_between {
			display: flex;
			justify-content: space-between;
		}

		.popup_data_item {
			height: 50px;
			display: flex;
			border-bottom: 1px solid #EEE;
			align-items: center;

			.popup_label {
				width: 75px;
				color: #999;
			}

			.popup_value {
				font-weight: 700;
				width: 168px;
			}

			.popup_copy {
				background-color: $common-red;
				color: #fff;
				padding: 3px 10px;
				border-radius: 12px;
				margin-left: auto;
			}
		}

		.popup_btn {
			background: $common-red;
			color: #fff;
			height: 40px;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 5px;
			margin-top: 15px;
		}
	}


	.fengcun {
		width: 90px;
		background-color: #fff;
		margin: 10px 0;
		border-radius: 3px;
		border: 1px solid $common-red;
		color: $common-red;
		padding: 5px 0;
		display: flex;
		justify-content: center;
	}

	.code_pay_view {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		width: 320px;

		.name_text {
			margin: 15px 0;
			font-size: 18px;
			font-weight: 700;
		}

		image {
			width: 150px;
			height: 150px;
		}
	}
</style>